package com.bankcomm.gradle.controller;

import com.bankcomm.gradle.entity.User;
import com.bankcomm.gradle.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xuwanxing
 * @date 2020/5/29
 */
@RestController
public class AccountController {

    @Autowired
    private UserMapper userMapper;

    @RequestMapping(value = "/insert", produces = {"application/json; charset=UTF-8"})
    @ResponseBody
    public String insertUser() {
        User user = new User();
        user.setName("sssssasas");
        user.setPhone("44555");
        user.setAddress("sss");
        userMapper.insert(user);
        return user.toString();
    }

    @RequestMapping(value = "/findAll", produces = {"application/json; charset=UTF-8"})
    public List<User> findAll() {
        return userMapper.selectAll();
    }


}
